﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using WebHoiChoMuaBan.Models;

namespace WebHoiChoMuaBan.Controllers.Helpers
{
    public class GroupHelper : HelperBase
    {
        private Group group;

        public GroupHelper() : base()
        {
        }

        public GroupHelper(int groupID) : base()
        {
            this.group = this.dataContext.Groups.SingleOrDefault(g => g.GroupID == groupID);
        }

        public Group GetGroupID(int groupID)
        {
            this.group = this.dataContext.Groups.SingleOrDefault(g => g.GroupID == groupID);
            return this.group;
        }

        public Group this[int groupID]
        {
            get 
            {
                return this.group;
            }

            set 
            {
                this.group = value;
            }
        }

        public void Save()
        {
            this.dataContext.Member_Groups.InsertAllOnSubmit(this.group.Member_Groups);
            this.dataContext.SubmitChanges();
        }
    }
}